#ifndef _SRC_NET_HTTP_HTTP_REQUEST_H_
#define _SRC_NET_HTTP_HTTP_REQUEST_H_

#include <cassert>
#include <cstdio>
#include <map>
#include <string>
#include <string_view>

#include "src/base/time_stamp.h"
#include "src/base/utils.h"

namespace fio66::net {
enum class HttpMethod { kInvalid, kGet, kPost, kHead, kPut, kDelete, };

enum class HttpVersion { kUnknow, kHttp10, kHttp11, };

class HttpRequest {
 public:
  HttpRequest() = default;
  ~HttpRequest() = default;

  void SetVersion(HttpVersion v);
  HttpVersion Version() const;
  std::string_view VersionString() const;

  bool SetMethod(std::string_view method);
  HttpMethod Method() const;
  std::string_view MethodString() const;

  void SetPath(std::string_view path);
  std::string_view Path() const;

  void SetQuery(std::string_view query);
  std::string_view Query() const;

  void SetReceiveTime(Timestamp t);
  Timestamp ReceiveTime() const;

  void AddHeader(const char* start, const char* colon, const char* end);
  std::string_view GetHeader(const std::string& field) const;

  const std::map<std::string, std::string> Headers() const;

  void Swap(HttpRequest& that);

 private:
  HttpMethod method_ = HttpMethod::kInvalid;
  HttpVersion version_ = HttpVersion::kUnknow;
  std::string path_;
  std::string query_;
  Timestamp receive_time_;
  std::map<std::string, std::string> headers_;
};

}  // namespace fio66::net

#endif  // _SRC_NET_HTTP_HTTP_REQUEST_H_
